package com.cc.response;

public class ServerResponse<T> {
    private int code;
    private String msg;
    private long count;
    private T data;

    private ServerResponse(int code, String msg, long count, T data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public ServerResponse(int code, String msg) {
        this.code =code;
        this.msg = msg;
    }

    public static <T> ServerResponse<T> successMsg(long count, T data) {
        return new ServerResponse<T>(200, "请求成功", count, data);
    }
    
    public static <T> ServerResponse<T> failedMsg() {
        return new ServerResponse<T>(500, "请求失败");
    }
    public static <T> ServerResponse<T> failedMsg(int code, String msg) {
        return new ServerResponse<T>(code, msg);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

}
